package jinx.lbj.springcloud_model;

import jinx.lbj.springcloud_model.feign.GameFeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@SpringBootApplication
@EnableEurekaClient
@EnableFeignClients
@RestController
public class SpringcloudModelApplication {

	public static void main(String[] args) {
		SpringApplication.run(SpringcloudModelApplication.class, args);
	}

	@Autowired
	private GameFeign gameFeign;

	@Value("${server.port}")
	String port;

	@RequestMapping("/hi")
	public String home(@RequestParam(value = "name", defaultValue = "forezp") String name) {
		return "hi " + name + " ,i am from port:" + port;
	}

	@RequestMapping("/getGames")
	public List<Map> getGames() {
		return gameFeign.getGames();
	}
}
